package com.jprocms.module.cms.service.sensitivetask;

import com.jpro.framework.common.pojo.PageResult;
import com.jprocms.module.cms.controller.admin.sensitivetask.vo.TaskSensitiveResultCreateReqVO;
import com.jprocms.module.cms.controller.admin.sensitivetask.vo.TaskSensitiveResultListReqVO;
import com.jprocms.module.cms.controller.admin.sensitivetask.vo.TaskSensitiveResultPageReqVO;
import com.jprocms.module.cms.convert.tasksensitiveresult.TaskSensitiveResultConvert;
import com.jprocms.module.cms.dal.dataobject.tasksensitiveresult.TaskSensitiveResultDO;
import com.jprocms.module.cms.dal.mysql.sensitivetask.TaskSensitiveResultMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * 敏感词扫描任务结果 Service 实现类
 *
 * @author jprocms
 */
@Service
@Validated
public class SensitiveTaskServiceImpl implements SensitiveTaskService {

    @Resource
    private TaskSensitiveResultMapper taskSensitiveResultMapper;

    @Override
    public Long createTaskSensitiveResult(TaskSensitiveResultCreateReqVO createReqVO) {
        // 插入
        TaskSensitiveResultDO taskSensitiveResult = TaskSensitiveResultConvert.INSTANCE.convert(createReqVO);
        taskSensitiveResultMapper.insert(taskSensitiveResult);
        // 返回
        return taskSensitiveResult.getId();
    }

    @Override
    public void deleteTaskSensitiveResult(Long id) {
        // 删除
        taskSensitiveResultMapper.deleteById(id);
    }

    @Override
    public TaskSensitiveResultDO getTaskSensitiveResult(Long id) {
        return taskSensitiveResultMapper.selectById(id);
    }

    @Override
    public List<TaskSensitiveResultDO> getTaskSensitiveResultList(Collection<Long> ids) {
        return taskSensitiveResultMapper.selectBatchIds(ids);
    }

    @Override
    public PageResult<TaskSensitiveResultDO> getTaskSensitiveResultPage(TaskSensitiveResultPageReqVO pageReqVO) {
        return taskSensitiveResultMapper.selectPage(pageReqVO);
    }

    @Override
    public List<TaskSensitiveResultDO> getTaskSensitiveResultList(TaskSensitiveResultListReqVO exportReqVO) {
        return taskSensitiveResultMapper.selectList(exportReqVO);
    }

}
